

#import "c_np_manager.h"
#import "oc_np_manager.h"


#import "SDL2/include/SDL.h"
#import "SDL2/include/SDL_video.h"
#import "SDL2/include/SDL_syswm.h"



OC_NPmanager* pNPManager = nil;

static OnCDashBoardShowCB    CallBackDashBoardShow = 0;
static OnCDashBoardHideCB    CallBackDashBoardHide = 0;


void  CInitNextPeer (
                  const char*                     pKey,
                  OnCDashBoardShowCB    POnCDashBoardShowCB,
                  OnCDashBoardHideCB    POnCDashBoardHideCB
                 )
{
    if(pNPManager == nil)
    {
        pNPManager = [OC_NPmanager alloc];
    }
    
    CallBackDashBoardShow = POnCDashBoardShowCB;
    CallBackDashBoardHide = POnCDashBoardHideCB;

    
    NSString *pNSKey = [[NSString alloc] initWithUTF8String:pKey];
    [pNPManager Init:pNSKey];
        
    
    
}

void  CReportScoreNextPeer(int Score)
{
    if(pNPManager)
        [pNPManager ReportScore:Score];
}

void  CLaunchDashboardNextPeer(void)
{
    if(pNPManager)
        [pNPManager LaunchDashBoard];
}


void OnCTournamentStartWithDetailsNextPeer(void)
{
 
}


void  CShutDownNextPeer(void)
{
     if(pNPManager)
         [pNPManager release];
    
    pNPManager = nil;
}

void 	CReportForfeitForCurrentTournament(void)
{
    if(pNPManager)
        [pNPManager ReportForfeitForCurrentTournament];
}

void 	CReportControlledTournamentOver(int Score)
{
    if(pNPManager)
        [pNPManager ReportControlledTournamentOver:Score];
}

void 	CSetCurrentTournament(const char* LevelID)
{
    NSString *pNSID = [[NSString alloc] initWithUTF8String:LevelID];
    
    if(pNPManager)
       [pNPManager SetCurrentTournament:pNSID];
}


/**
 This is where OpenGL games should unpause and resume playback.
 */
void CNextpeerDashboardDidDisappear(void)
{
    if(CallBackDashBoardHide)
    {
        CallBackDashBoardHide();
    }
}

/**
 This is where you should pause your game.
 */
void CNextpeerDashboardWillAppear(void)
{
    if(CallBackDashBoardShow)
    {
        CallBackDashBoardShow();
    }
    
}

